
# The user of this replication package should set their working directory to 
# the replication package folder `retraumatization_replication_package`, to run 
# this code.
setwd("")

################################################################################
################################# FIGURE 1 #####################################
################################################################################

# This code reproduces Figure 1 in the article; it reads in the data, filters to
# the appropriate range of years, then produces a line plot.

df <- read.csv("trauma_mentions_big_3.csv")

df2 <- df[which(df$Year>=2000 & df$Year < 2024), ]

df3 <- data.frame(table(df2$Year))

df3 <- apply(df3, 2, as.integer)

df4 <- data.frame(Var1 = 2000:2023)

df5 <- dplyr::full_join(as.data.frame(df3), as.data.frame(df4), by = "Var1") |>
  dplyr::arrange(Var1)

df5$Freq <- ifelse(is.na(df5$Freq), 0, df5$Freq)

par(mar = c(4.1, 4.1, 3, 2.1))
plot(df5$Freq ~ df5$Var1,
     type = "l",
     axes = FALSE,
     lwd = 2,
     xlab = "",
     ylab = "",
     ylim = c(0, 12))
axis(1, 
     at = seq(2000, 2023, 1), 
     col = "darkgray", 
     col.axis = "darkgray", 
     labels = FALSE)
text(seq(2000, 2023, by = 1), 
     par("usr")[3] - 0.5, 
     srt = 50, 
     adj = 1, 
     xpd = TRUE, 
     labels = df5$Var1, cex = 0.7,
     col = "black")
axis(2,
     #yaxp = c(0, 12, 6),
     at = seq(0, 12, 2), 
     col = "darkgray", 
     col.ticks = "darkgray",
     col.axis = "black",
     las = 1, 
     cex.axis = 0.8)
mtext("Articles", side = 2, line = 2.3, cex = 1.25)
mtext("Year", side = 1, line = 2.6, cex = 1.25)
mtext("Discussions of Trauma", side = 3, cex = 1.5)

################################################################################
################################# FIGURE 2 #####################################
################################################################################

# This code reproduces Figure 2 in the article; it reads in the data, filters to
# the appropriate range of years, then produces a line plot.

df <- read.csv("violence mentions in the big three.csv")

df <- df[df$Year < 2024, ]

frequencies <- data.frame(table(df$Year))
frequencies <- data.frame(Freq = frequencies$Freq, 
                          Var1 = as.numeric(unique(levels(frequencies$Var1))))
df <- data.frame(Var1 = 2000:2023)
frequencies <- dplyr::full_join(df, frequencies, by = "Var1")
frequencies$Freq <- ifelse(is.na(frequencies$Freq) == TRUE, 0, frequencies$Freq)

par(mar = c(4.1, 4.1, 3, 2.1))
plot(frequencies$Freq ~ frequencies$Var1,
     type = "l",
     axes = FALSE,
     xlab = "",
     ylab = "",
     lwd = 2)
axis(1, 
     at = seq(2000, 2023, 1), 
     col = "darkgray", 
     col.axis = "darkgray", 
     labels = FALSE)
text(seq(2000, 2023, by = 1), 
     par("usr")[3] - 0.75, 
     srt = 50, 
     adj = 1, 
     xpd = TRUE,
     labels = frequencies$Var1, cex = 0.7,
     col = "black")
axis(2, 
     at = seq(0, 20, 2), 
     col = "darkgray", 
     col.ticks = "darkgray", 
     col.axis = "black",
     las = 1,
     cex.axis = 0.8)
mtext("Articles", side = 2, line = 2.3, cex = 1.25)
mtext("Year", side = 1, line = 2.6, cex = 1.25)
mtext("Human Subjects Data Collection about Violence", side = 3, cex = 1.5)


